package com.jeeplus.modules.report.web;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.report.service.ReportTestService;
import com.jeeplus.modules.test.one.dialog.entity.Leave1;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author Administrator
 * @title: ReportTestControler
 * @projectName jeeplus
 * @description: TODO
 * @date 2019/7/3015:14
 */
@Controller
@RequestMapping(value = "${adminPath}/Report")
public class ReportTestControler extends BaseController {
    @Autowired
    ReportTestService reportService;
    @RequiresPermissions("report:list")
    @RequestMapping(value = {"list1", ""})
    public String list(Leave1 leave1, Model model) {
        model.addAttribute("leave1", leave1);

        return "modules/Report/test";
    }
    @RequiresPermissions({"report:list"})
    @RequestMapping({"saleDiffList", ""})
    public String saleDiffList(Model model) { return "modules/Report/saleDiffList"; }

    @ResponseBody
    @RequiresPermissions({"report:list"})
    @RequestMapping({"saleDiffData"})
    public Map<String, Object> saleDiffData(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
        Page page = new Page(request, response);
        System.out.println(String.format("%s,%s", new Object[] { Integer.valueOf(page.getPageNo()), Integer.valueOf(page.getPageSize()) }));

        return this.reportService.getSaleDiffList(page.startRow(), page.endRow());
    }
}
